<template lang="">
    <div class="main">
        <van-nav-bar title="随访列表" />

        <div class="chat-item" v-for="(group ,index) in groups" :key="index" @click="goChat(group.patient_id)">
            <div class="item-left">
                <div class="patient-name">{{group.patient_name}}</div>
                <div class="item-msg">{{group.msg}} </div>
            </div>
            <div class="item-time">
                {{group.msg_time}}
            </div>
        </div>
    </div>
</template>
<script>
import { ref, reactive,onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { getDocGroup} from "../api/index"
import { getUserInfo, log, LOCAL_USER } from "../utils/user"
import { showToast, showConfirmDialog } from 'vant';
import router from '../router';
export default {
    setup() {
        const groups = ref([])
        onMounted(() => {
            getDocGroup({}).then(res => {
                if(res.status == 'ok'){
                    groups.value =res.data
                }
                showToast(res.msg)
            })
        })
        const goChat = id => {
            router.push("Chat/"+id)
        }
        return {
            groups,
            goChat
        }
    }
}
</script>
<style scoped>
.main{
    padding: 15px;
}

.item-left{
    max-width: 60%;
}
.item-msg{
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #A0A0A0;
    margin-top: 5px;
}
.chat-item{
    display: flex;
    justify-content: space-between;
    padding: 10px;
    align-items: end;
}
.item-time{
    font-size: 12px;
}
</style>